<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改优惠卷模板')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-discount-edit" th:object="${discount}">
            <input name="uuid" th:field="*{uuid}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">优惠卷名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">剩余数量：</label>
                <div class="col-sm-8">
                    <input name="num" th:field="*{num}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">最大领取次数：</label>
                <div class="col-sm-8">
                    <input name="maxNumber" th:field="*{maxNumber}" class="form-control" type="text">
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">领取条件字段：</label>-->
<!--                <div class="col-sm-8">-->
<!--&lt;!&ndash;                    <input name="conditionField" th:field="*{conditionField}" class="form-control" type="text">&ndash;&gt;-->
<!--                    <select name="conditionField" class="form-control m-b" th:with="type=${@dict.getType('dd_user_field')}">-->
<!--&lt;!&ndash;                        <option  th:value="${@dict.getLabel('dd_discount')}"></option>&ndash;&gt;-->
<!--                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
<!--                                th:if="${discount.conditionField} ne ${dict.dictValue}" th:value="${dict.dictValue}"></option>-->
<!--                    </select>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">条件限制：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="conditionalit" th:field="*{conditionalit}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">优惠额度：</label>
                <div class="col-sm-8 input-group">
                    <input name="quota" th:field="*{quota}" class="form-control" type="text">
                    <span class="input-group-addon">%</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">有效期模式：</label>
                <div class="col-sm-8">
                    <input name="dateType"  th:value="${@dict.getLabel('dd_discount',discount.dateType)}" class="form-control" type="text" disabled>
                </div>
            </div>

            <div>
                <div class="form-group" th:if="${discount.dateType} eq 0">
                    <label class="col-sm-3 control-label">有效期起始日：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input name="beginTime" th:value="${#dates.format(discount.beginTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        </div>
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 开始时间为选择当天的00：00开始</span>
                    </div>
                </div>
                <div class="form-group"  th:if="${discount.dateType} eq 0">
                    <label class="col-sm-3 control-label">有效期结束日：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input name="endTime" th:value="${#dates.format(discount.endTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        </div>
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 结束时间为选择当天的23：59结束</span>
                    </div>
                </div>
                <div class="form-group" th:if="${discount.dateType} eq 1">
                    <label class="col-sm-3 control-label">领取后有效期天数：</label>
                    <div class="col-sm-8">
                        <input name="dateNumber" th:field="*{dateNumber}" class="form-control" type="text">
                    </div>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remake" th:field="*{remake}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/discount";
        $("#form-discount-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-discount-edit').serialize());
            }
        }

        $("input[name='beginTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>